package com.ruoyi.lhky.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.lhky.mapper.*;
import com.ruoyi.lhky.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StatusService extends ServiceImpl<StatusMapper, Status> {

    @Autowired
    V0Mapper v0Mapper;

    @Autowired
    V1Mapper v1Mapper;

    @Autowired
    V2Mapper v2Mapper;

    @Autowired
    V3Mapper v3Mapper;

    @Autowired
    V4Mapper v4Mapper;

    @Autowired
    StudyCompletionMapper studyCompletionMapper;

    public Status getStatusByTesterId(Long testerId){
        System.out.println(testerId);
        Status status = new Status();
        try {
            status.setV0Status(v0Mapper.selectOne(new QueryWrapper<V0>().eq("tester_id", testerId)).getStatus());
        }catch (Exception e){
//            e.getMessage();
        }
        try {
            status.setV1Status(v1Mapper.selectOne(new QueryWrapper<V1>().eq("tester_id", testerId)).getStatus());
        }catch (Exception e){
//            e.getMessage();
        }
        try {
            status.setV2Status(v2Mapper.selectOne(new QueryWrapper<V2>().eq("tester_id", testerId)).getStatus());
        }catch (Exception e){
//            e.getMessage();
        }
        try {
            status.setV3Status(v3Mapper.selectOne(new QueryWrapper<V3>().eq("tester_id", testerId)).getStatus());
        }catch (Exception e){
//            e.getMessage();
        }
        try {
            status.setV4Status(v4Mapper.selectOne(new QueryWrapper<V4>().eq("tester_id", testerId)).getStatus());
        }catch (Exception e){
//            e.getMessage();
        }
        try {
            status.setStudyCompletionStatus(studyCompletionMapper.selectOne(new QueryWrapper<StudyCompletion>().eq("tester_id", testerId)).getStatus());
        }catch (Exception e){
//            e.getMessage();
        }
        System.out.println(status);
        return status;
    }
}
